using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using StackExchange.Redis;

namespace Crossborder.Common.RedisModule
{
    public partial class RedisWorker
    {
        public List<string> GetRedisZSet(string key)
        {
            List<string> result = new();
            var idxs = RedisCore.db.SetMembers(key);
            foreach (var idx in idxs)
            {
                result.Add(idx.ToString());
            }
            return result;
        }

        public async Task<List<string>> GetRedisZSetAsync(string key)
        {
            List<string> result = new();
            var idxs = await RedisCore.db.SetMembersAsync(key);
            foreach (var idx in idxs)
            {
                result.Add(idx.ToString());
            }
            return result;
        }

        public void SetRedisZSet(string key, string value)
        {
            RedisCore.db.SetAdd(key, value);
        }

        public async Task SetRedisZSetAsync(string key, string value)
        {
            await RedisCore.db.SetAddAsync(key, value);
        }
    }
}